Skip to content

feat: add OpenAI Runner protocol implementation (AIC-2388)#1337

Draft
jsonbailey wants to merge 1 commit intojb/aic-2388/js-runner-protocolfrom
jb/aic-2388/js-openai-runner
Draft

feat: add OpenAI Runner protocol implementation (AIC-2388)#1337
jsonbailey wants to merge 1 commit intojb/aic-2388/js-runner-protocolfrom
jb/aic-2388/js-openai-runner

Conversation

@jsonbailey
Copy link
Copy Markdown
Contributor

Summary

Adds Runner-protocol classes for the OpenAI provider, replacing the deprecated AIProvider extension model introduced in earlier work. New classes:

  • OpenAIModelRunnerRunner for chat completions; run(messages, outputType?) returns RunnerResult { content, metrics, raw, parsed? }. Structured output is parsed automatically via OpenAI's json_schema response format.
  • OpenAIAgentRunnerRunner for a single agent. Runs a tool-calling loop using the OpenAI Chat Completions API. Tool definitions come from config.model.parameters.tools; tool callables come from a caller-supplied ToolRegistry. Populates LDAIMetrics.toolCalls with the names of tools the model invoked.
  • OpenAIRunnerFactory — exposes createModel(config) and createAgent(config, tools?). Shares one OpenAI client across all runners produced by the factory.
  • convertMessagesToOpenAI, getAIMetricsFromResponse, getAIUsageFromResponse — helper functions usable from a tracker's trackMetricsOf.

The legacy OpenAIProvider class is preserved so AIProviderFactory (also @deprecated) keeps working until the managed layer fully migrates to Runner.run().

Stacked on jb/aic-2388/js-runner-protocol (JS PR 6).

Test plan

  • yarn workspace @launchdarkly/server-sdk-ai-openai test — 33 tests pass (existing 13 + 20 new for the Runner classes / helpers)
  • yarn workspace @launchdarkly/server-sdk-ai-openai lint — clean
  • yarn workspace @launchdarkly/server-sdk-ai-openai run build — clean

🤖 Generated with Claude Code

@jsonbailey jsonbailey force-pushed the jb/aic-2388/js-runner-protocol branch from 635cf16 to 2286917 Compare May 1, 2026 14:07
Adds OpenAIModelRunner, OpenAIAgentRunner, and OpenAIRunnerFactory that
implement the Runner protocol introduced in JS PR 6. The runners take an
LDAICompletionConfig / LDAIAgentConfig at construction and expose
run(prompt: string) returning RunnerResult.

OpenAIModelRunner.run(prompt) prepends the config's messages before the
user prompt. OpenAIAgentRunner runs a tool-calling loop using the OpenAI
Chat Completions API, populating LDAIMetrics.toolCalls with the names of
tools the model invoked. Tool implementations are supplied via a
ToolRegistry passed to OpenAIRunnerFactory.createAgent.

The deprecated OpenAIProvider class is preserved so AIProviderFactory
continues to work during the migration.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@jsonbailey jsonbailey force-pushed the jb/aic-2388/js-openai-runner branch from 07f1af2 to 66bb862 Compare May 1, 2026 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant